package na.learn.java.threads;

public class EvaluateString {

	public EvaluateString() {
		super();

	}

	public static void testSimpleStrings() {
		System.out.println("test Strings using quoted Strings");
		String a = "hello1";
		String b = "hello1";
		String c = a.substring(0);
		if (a == b)
			System.out.println("equal");
		if (a == c)
			System.out.println("substring points to same");

	}

public static void testNewStrings() {
		System.out.println("\n test Strings using new operator.");
		String a = new String("hello1");
		String b = new String("hello1");
		String c = new String(a.substring(0));
		StringBuffer msg = new StringBuffer();;
		if(a==b)
			System.out.println("new String(\"hello1\") equal to new String(\"hello1\")");
		else
			System.out.println("new String(\"hello1\") not equal to new String(\"hello1\")");
		if(a==c)
			System.out.println("substring points to same");
		
		String d = "hello";
		String e =  "hello".intern();
		
		
		String f = new String("hello").intern();
		if(d==e)
			System.out.println("intern simple string points to same");
		if(d==f)
				System.out.println("intern new string points to same");
		
	}	public static void main(String[] args) {

		testSimpleStrings();
		testNewStrings();

	}

}
